const ARule = require('./ARule');


class RandomRule extends ARule {

    /**
     * 通过随机规则选择一个服务节点
     * @param {String} service 
     * @param {Array<String>} nodes 
     * @returns 服务节点
     */
    choose(service, nodes) {
        let node = nodes[Math.floor(Math.random() * nodes.length)];
        console.debug(`random choose : ${service} ${node}`);
        return node;
    }

}


module.exports = RandomRule;